// 高德地图API

var baseUrl = 'https://restapi.amap.com/v3/place' //高德地图api
var key = 'ef192993779acc28bed07c24231fe15b' //高德地图web端的秘钥

function http(obj) {

	return new Promise((resolve, reject) => {
		obj.data.key = key //秘钥

		// 基本的配置
		var setting = {
			url: baseUrl + obj.url, //URL地址
			data: obj.data, //参数
			method: obj.method.toUpperCase() || 'GET', //默认是get方法
			header: {
				'content-type': 'application/x-www-form-urlencoded',
				'content-type': 'application/json;charset=UTF-8'
			}
		}
		// 请求数据 请求成功失败在这里处理
		uni.request({
			...setting,
			success(res) {
				res.data.status == '1' ? resolve(res) : ''
				},
			fail(err) {
				
			}
		})
	})
}


// 关键字查询
export function keyWordsSearch(data) {
	return http({
		url: '/text',
		method: "GET",
		amap: true,
		data: data
	})
}

// 周边查询
export function aroundSearch(data) {
	return http({
		url: '/around',
		method: "GET",
		amap: true,
		data: data
	})
}

// 逆地理解析位置 
export function regeo(data) {
	return http({
		url: '/regeo',
		method: "GET",
		amap: true,
		data: data
	})
}
